<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>props的值是对象</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3>父级数据</h3>
        <p>姓名：{{ name }}，年龄：{{ age }}</p>
        <my-component :age="age" :name="name"></my-component>
    </div>

    <template id="temp">
        <div>
            <h3>传到子组件修改后数据：</h3>
            子组件姓名：{{ myname }}，年龄：{{ myage }}，爱好：{{ love }}
        </div>
    </template>

    <script type="text/javascript">
        Vue.component('my-component', {
            props: {
                name: String,
                age: Number,
                love: {
                    type:String,
                    default: 'playgame'
                }
            },
            template: '#temp',
            data: function () {
                return {
                    myname: '小'+this.name,
                    myage: this.age-10
                }
            }
        });

        var app = new Vue({
            el: '#app',
            data: {
                name: '张三',
                age: 18
            },
        });
    </script>
</body>
</html>